package teams

import (
	"itodo/core/dao/table"
	"itodo/core/dao/teamdao"
	"itodo/core/localwrap"
)

var logTeams = localwrap.GetLogger().Fork("itodo/core/service/teams", "Teams")

type Teams struct{}

func (s Teams) Query(param teamdao.TeamsQueryParam) ([]table.Team, int64) {
	logTeams.Debug().Func("Query").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return teamdao.Teams{RedisedMysql: d}.Query(param)
}

func (s Teams) Get(id int) table.Team {
	logTeams.Debug().Func("Get").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return teamdao.Teams{RedisedMysql: d}.Get(id)
}

func (s Teams) Add(param teamdao.TeamsAddParam) table.Team {
	logTeams.Debug().Func("Add").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return teamdao.Teams{RedisedMysql: d}.Add(param)
}

func (s Teams) Update(param teamdao.TeamsUpdateParam) {
	logTeams.Debug().Func("Update").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	teamdao.Teams{RedisedMysql: d}.Update(param)
}

func (s Teams) Delete(id int) {
	logTeams.Debug().Func("Delete").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	teamdao.Teams{RedisedMysql: d}.Delete(id)
}
